package com.siyu.preplan.planpdepot.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.siyu.common.core.controller.BaseController;
import com.siyu.common.core.domain.AjaxResult;
import com.siyu.common.core.page.TableDataInfo;
import com.siyu.common.utils.poi.ExcelUtil;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.siyu.preplan.planpdepot.domain.PlanPDepot;
import com.siyu.preplan.planpdepot.service.IPlanPDepotService;

/**
 * 预案仓库基础信息Controller
 *
 * @author hrhy
 * @date 2024-08-14
 */
@RestController
@RequestMapping("/planpdepot/PlanPDepot")
public class PlanPDepotController extends BaseController
{
    @Autowired
    private IPlanPDepotService planPDepotService;

    /**
     * 查询预案仓库基础信息列表
     */
    @GetMapping("/list")
    public TableDataInfo list(PlanPDepot planPDepot)
    {
        startPage();
        List<PlanPDepot> list = planPDepotService.selectPlanPDepotList(planPDepot);
        return getDataTable(list);
    }

    /**
     * 导出预案仓库基础信息列表
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response, PlanPDepot planPDepot)
    {
        List<PlanPDepot> list = planPDepotService.selectPlanPDepotList(planPDepot);
        ExcelUtil<PlanPDepot> util = new ExcelUtil<PlanPDepot>(PlanPDepot.class);
        util.exportExcel(response, list, "预案仓库基础信息数据");
    }

    /**
     * 获取预案仓库基础信息详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(planPDepotService.selectPlanPDepotById(id));
    }

    /**
     * 新增预案仓库基础信息
     */
    @PostMapping
    public AjaxResult add(@RequestBody PlanPDepot planPDepot)
    {
        return toAjax(planPDepotService.insertPlanPDepot(planPDepot));
    }

    /**
     * 修改预案仓库基础信息
     */
    @PutMapping
    public AjaxResult edit(@RequestBody PlanPDepot planPDepot)
    {
        return toAjax(planPDepotService.updatePlanPDepot(planPDepot));
    }

    /**
     * 删除预案仓库基础信息
     */
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(planPDepotService.deletePlanPDepotByIds(ids));
    }
}
